
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "atom.h"


double atom_distance (struct atom * a, struct atom * b) {


  double x = ((double)a->x) - ((double)b->x);
  double y = ((double)a->y) - ((double)b->y);
  double z = ((double)a->z) - ((double)b->z);

  //It could make sense to calculate hypot(hypot(x,y),z) instead, but I doubt it.

  x=x*x;
  y=y*y;
  z=z*z;
  
  return sqrt(x+y+z);  
}

void atom_print (struct atom * a) {
  char name[5];
  char elem[3];
  strncpy(name, a->name, 4);
  name[4] = '\0';
  strncpy(elem, a->element, 2);
  elem[2] = '\0';
  printf("{#=%d name = '%s', element = '%s', residue = %c %d, x,y,z = (%d,%d,%d) temp = %d}\n", 
	 a->serialNumber,
	 name,
	 elem,
	 a->chain,
	 a->residue,
	 a->x, a->y, a->z, 
	 a->temperature);
}
